package com.foreveredu.propms.web.struts.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.foreveredu.propms.domain.News;
import com.foreveredu.propms.domain.SubDistrict;
import com.foreveredu.propms.service.IManagementService;

public class IndexAction extends AbstractBaseDispatchAction {
	private IManagementService managementService = null;

	public IManagementService getManagementService() {
		return managementService;
	}

	public void setManagementService(IManagementService managementService) {
		this.managementService = managementService;
	}
	public ActionForward toIndex(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		int belong = 1 ;
		List<News> news = managementService.findNewsListView(belong);
		request.setAttribute("newsList", news);
		
		belong = 2 ;
		
		List<News> zcfg = managementService.findNewsListView(belong);
		request.setAttribute("zcfgList", zcfg);
		
		belong = 3 ;
		News gsjj = managementService.findNewsByBelong(belong);
		request.setAttribute("gsjj", gsjj);
		
		return mapping.findForward("index");
	}
	
	public ActionForward subDistrictList(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		List<SubDistrict> subDistrictList = managementService
				.findSubDistricts();
		request.setAttribute("subDistrictList", subDistrictList);

		return mapping.findForward("subDistrictList");
	}
}
